<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">注册</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">
			    <div class="mui-input-row">
			        <label>账号:</label>
			        <input type="text" class="mui-input-clear" placeholder="请输入账号"id="account">
			    </div>
			    <div class="mui-input-row">
			        <label>昵称:</label>
			        <input type="text" class="mui-input-clear" placeholder="请输入昵称"id="nickname">
			    </div>
			    <div class="mui-input-row">
			        <label>密码:</label>
			        <input type="password" class="mui-input-clear" placeholder="请输入密码"id="password">
			    </div>
			    <div class="mui-input-row">
			        <label>确认密码:</label>
			        <input type="password" class="mui-input-clear" placeholder="确认密码"id="sureword">
			    </div>
			</form>
			<div class="mui-content-padded"align="center">
				<a href="javascript:;"class="mui-btn mui-btn-royal mui-btn-block"style="height: 30px;line-height: 0px;"id="reg">注册</a>
			</div>
		</div>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.plusReady(function(){
				var regButton = document.getElementById("reg");
				regButton.addEventListener('tap',function(){
					var account = document.getElementById("account");
					var mpassword = document.getElementById("password");
					var nickname = document.getElementById("nickname");
					var spassword = document.getElementById("sureword");
					//如果两个值不相同的时候就不让其跳转
					if(nickname.value != spassword.value){
						plus.ui.toast('两次密码不相同');
						return;
					}
					//如果两次密码相同的时候，就发送ajax数据
					mui.ajax('http://api.jiunixing.com/appNews/index.php?c=Account&a=reg',{
						data:{
							account:account.value,
							password:mpassword.value,
							nickname:nickname.value,
						},
						type:'post',
						dataType:'json',
						timeout:15000,
						success:function(data){
							plus.ui.toast(data.msg);
							//如果返回的页面是1
							if(data.status == 1){
								//跳转到登陆页面
								mui.openWindow({
									//跳转到首页的登陆页面
									url : './index.html',
									timeout:15000,
									id:'index',
									show:{
										ainShow:'pop-in',
									}
								})
							}
						},
						error:function(){
							plus.ui.toast('网络不同或者错误');
						}
					})
				})
			});
			
		</script>
	</body>

</html>